//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// 

#ifndef AODV_UU_STIMULUS_H_
#define AODV_UU_STIMULUS_H_

#include "aodv_uu_omnet.h"
#include "ManetRoutingCallable.h"

#include "applications/stemNetStimulus/KnowledgeRepository.h"
#include "applications/stemNetStimulus/TypeDefinitions.h"


#undef NS_NO_GLOBALS
#define NS_NO_DECLARATIONS
#include "aodv-uu/aodv_status.h"
#undef NS_NO_DECLARATIONS


class AODVUU_STIMULUS : public AODVUU, public ManetRoutingCallable
{
public:
    AODVUU_STIMULUS() : AODVUU() {};

    void clearPiggyBackInfo(void);
    void setMyPiggyBackInfo(void *info_p);
    bool addNewPiggyBackInfo(void *info_p);

    ManetAddress getManetAddress() const {return getAddress();}

protected:
    virtual void initialize(int stage);

    virtual void rreq_forward(RREQ * rreq, int size, int ttl);
    virtual int startAODVUUAgent();

    virtual bool checkRREQ_stimulus(uint8_t stim);

    virtual void status_process(RSTATUS_MSG * status, int rstatuslen, unsigned int ifindex);
    virtual RSTATUS_MSG *rstatus_create( struct in_addr dest_addr, u_int32_t dest_seqno, struct in_addr orig_addr, ManetAddress my_addr);

    virtual void aodv_socket_process_packet(AODV_msg * aodv_msg, int len,
                                    struct in_addr src,struct in_addr dst, int ttl,
                                    unsigned int ifindex);

    virtual RREQ *rreq_create(u_int8_t flags, struct in_addr dest_addr,
                      u_int32_t dest_seqno, struct in_addr orig_addr);
/*
#define NS_NO_GLOBALS
#undef NS_NO_DECLARATIONS

#undef AODV_STATUS_H_
#include "aodv-uu/aodv_status.h"

#undef NS_NO_GLOBALS
*/

protected:
    std::list<node_state_info_t> piggyback_neighbourhood_info;
    node_state_info_t piggyback_my_info;

private:
    KnowledgeRepository *db;
};

#endif /* AODV_UU_STIMULUS_H_ */
